<?php
/**
 * Created by PhpStorm.
 * User: yuyiwen
 * Date: 2018/9/13
 * Time: 下午3:51
 */

namespace app\admin\model;


class Permission
{
    public function getPermission ($permission_id)
    {
        $permission_list = db('permission')->where(['id'=>['in' , $permission_id]])->select();
        return $permission_list;
    }

    public function getMenus ($permission_id)
    {
        $role_ids = explode( ',', session('role_ids'));
        if (in_array(1 , $role_ids)){

            $permission_list = db('permission')->where(['type' => 1])->select();
        }else{

            $permission_list = db('permission')->where(['id'=>['in' , $permission_id]])->where(['type' => 1])->select();
        }

        return $permission_list;
    }
}